#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string s;

void add()
{
    string t = s;
    reverse(t.begin(), t.end());
    int len = s.length(), carry = 0;
    for (int i = 0; i<len; ++i)
    {
        s[i] = s[i] + t[i] + carry - '0';
        if (s[i] > '9')
        {
            s[i] = s[i] - 10;
            carry = 1;
        }
        else carry = 0;
    }
    if (carry == 1) s += '1';
    reverse(s.begin(), s.end());
}

int main()
{
    int limit;
    cin >> s >> limit;
    int step = 0;
    while (step < limit)
    {
        string t = s;
        reverse(t.begin(), t.end());
        if (s == t)
        {
            cout << s << endl << step;
            return 0;
        }
        step += 1;
        add();
    }
    cout << s << endl << step;
    return 0;
}

